<template>
	<div>
		<div class="head">
			<router-link tag="div" class="return" to="/My"></router-link>
			设置
		</div>
		<div class="overlay">
			<div class="overlay-content scrolling">
				<group label-width="9.5em" label-margin-right="2em" style="margin-top:10px;">
					<cell title="个人设置" is-link class="l-orange" link="/ModifyPersonal">昵称、签名、星座</cell>
					<cell title="安全设置" is-link class="l-orange" link="/Safety">密码</cell>
				</group>
				<group label-width="9.5em" label-margin-right="2em" style="margin-top:10px;">
					<cell title="版本号" :value="localVer" class="l-orange">

					</cell>
				</group>
				<div class="loginOut" @click="loginOut">退出登录</div>
			</div>
		</div>
	</div>
</template>

<script>
	import { Toast } from 'vant';
	import { base } from './../../utils/api';
	export default {
		data() {
			return {
				localVer: '0.0.1', //版本号
			}
		},
		mounted() {
			let _this = this
			_this.$nextTick(() => {
				setTimeout(() => {
					if(window.plus) {
						// 获取本地应用资源版本号
						plus.runtime.getProperty(plus.runtime.appid, function(inf) {
							_this.localVer = inf.version;
						});
					} else {
						base.getUpdate().then(res => {
							if(res.code == 200) {
								_this.localVer = res.data.android.ver;
							}
						})
					}
				}, 100);
			});
		},
		methods: {
			loginOut() { // 退出
				let _this = this
				this.$vux.confirm.show({
					title: '退出操作',
					content: '您确定要退出吗？',
					onConfirm() {
						base.getSignOut().then(res => {
							localStorage.clear()
							_this.axios.defaults.headers['Authorization'] = '';
							Toast(res.msg);
							_this.$router.push({
								path: '/Login'
							});
						})
					}
				})
			}
		}
	}
</script>

<style lang="less" scoped>
	.loginOut {
		background: #ffffff;
		text-align: center;
		color: #ff5555;
		padding: 10px 0;
		margin-top: 15px;
	}
</style>